package mahi.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Name2{
	String firstName;
	String lastName;
	int age;
	
	public Name2(String s1, String s2, int age1) {
		firstName = s1;
		lastName =s2;
		this.age = age1;
	}
	
	
	 public String toString() {
			return firstName + " " + lastName;
	}
	 
	 
	@Override
	public boolean equals(Object obj) {
		Name2 x= (Name2)obj;
		if(firstName.equals(x.firstName)){
			return true;
		}
		else{
			return false;
		}
	}
	
	
	@Override
	public int hashCode() {
		 return 31*firstName.hashCode();
	}
	
	 public static void main(String[] args) {
			Set<Name2> set = new HashSet<>();
			
			
			set.add(new Name2("mahender","singh",28));
			set.add(new Name2("mahender","singhxyz",28));
			
			System.out.println(set);
			
			Map<Name2, Integer> map = new HashMap<String, Integer>();
			map.put(new Name2("mahender","singh",28), 1);
			map.put(new Name2("mahender","singh123",28), 2);
			//bucket
			
			//33 -> create bucket(33) and store 1, 2 (Linkedlist)
				  //create bucket(45) and store 4
			
			
			
			
			
		}

}
